﻿<UserControl x:Class="Test.Silverlight.DataGrid.PreviewLayout"
    xmlns="http://schemas.microsoft.com/client/2007" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:Test.Silverlight.DataGrid;assembly=Test.Silverlight.DataGrid"
    xmlns:internal="clr-namespace:DevExpress.AgDataGrid.Internal;assembly=DevExpress.AgDataGrid.v8.2"
    xmlns:grid="clr-namespace:DevExpress.AgDataGrid;assembly=DevExpress.AgDataGrid.v8.2">

    <UserControl.Resources>
        <DataTemplate x:Name="OptionsPanelTemplate">
            <StackPanel x:Name="OptionsPanel" Orientation="Horizontal" Loaded="OptionsPanel_Loaded">
                <TextBlock Text="Preview Row Layout:" Margin="0,0,6,0" VerticalAlignment="Center"/>
				    <RadioButton x:Name="rbNormal" GroupName="1" Checked="rb_Checked" Margin="0,0,10,0" Content="Normal"/>
				    <RadioButton x:Name="rbToolTip" GroupName="1" Checked="rb_Checked" Margin="0,0,10,0" Content="ToolTip"/>
				    <RadioButton x:Name="rbOutside" GroupName="1" Checked="rb_Checked" Margin="0,0,10,0" Content="Outside"/>
                </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="GridPreviewTemplate">
            <Grid Margin="5,5,5,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.Resources>
                    <Style x:Name="BoldText" TargetType="TextBlock">
                        <Setter Property="FontWeight" Value="Bold"/>
                        <Setter Property="FontSize" Value="13"/>
                    </Style>
                    <Style x:Name="HeaderText" TargetType="TextBlock">
                        <Setter Property="FontSize" Value="16"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                    </Style>
                    <Style x:Name="ItalicText" TargetType="TextBlock">
                        <Setter Property="FontSize" Value="13"/>
                        <Setter Property="FontStyle" Value="Italic"/>
                    </Style>
                    <Style x:Name="NormalText" TargetType="TextBlock">
                        <Setter Property="FontSize" Value="13"/>
                    </Style>
                    <local:DateToLongDateStringConverter x:Name="DateToLongDateStringConverter"/>
                </Grid.Resources>
                <Grid VerticalAlignment="Top" HorizontalAlignment="Left" Margin="16,16,12,16" Grid.Row="0" Grid.Column="0">
                    <Grid.Resources>
                        <grid:AgDataGridImageColumnContentConverter x:Key="ImageContentConverter"/>
                    </Grid.Resources>
                    <Border Margin="5,5,0,0" Background="Black" Opacity="0.15" CornerRadius="5"
							HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                    <Border Background="#FF6E6E6E" CornerRadius="4,4,4,4" Padding="4"
							HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,5,5">
                        <Border Background="White" CornerRadius="2,2,2,2" Padding="3,3,3,3">
                            <Image x:Name="Icon" Source="{Binding Photo, Converter={StaticResource ImageContentConverter}}" Width="120" Height="127" />
                        </Border>
                    </Border>
                </Grid>
                <StackPanel Grid.Column="1" Grid.Row="0" Width="500" HorizontalAlignment="Left" Margin="0,16,0,0">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,0,6">
                        <TextBlock Style="{StaticResource HeaderText}" Text="{Binding FirstName}"/>
						<TextBlock Style="{StaticResource HeaderText}" Text=" "/>
						<TextBlock Style="{StaticResource HeaderText}" Text="{Binding LastName}"/>
					</StackPanel>
                    <local:FlowStackPanel>
                        <TextBlock Style="{StaticResource BoldText}"   Text="{Binding FirstName}"/>			
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding LastName}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="was born on"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding BirthDate, Converter={StaticResource DateToLongDateStringConverter}}"/>
						<TextBlock Style="{StaticResource NormalText}" Text=". Now lives at"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding City}"/>
						<TextBlock Style="{StaticResource NormalText}" Text=","/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding Country}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="."/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding TitleOfCourtesy}"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding LastName}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="holds a position of"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding Title}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="our"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding Region}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="department, ("/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding City}"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding Country}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="). Joined our company on"/>
						<TextBlock Style="{StaticResource BoldText}"   Text="{Binding HireDate, Converter={StaticResource DateToLongDateStringConverter}}"/>
						<TextBlock Style="{StaticResource NormalText}" Text="."/>
					</local:FlowStackPanel>
                    <Border Background="Transparent" Margin="0,0,0,6" />
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,16">
                        <TextBlock Style="{StaticResource BoldText}" Text="Notes:" Width="50"/>
					<TextBlock Width="450" TextWrapping="Wrap" Style="{StaticResource ItalicText}" Text="{Binding Notes}"/>
				</StackPanel>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <ContentControl x:Name="PreviewContent" Grid.Row="1" Visibility="Collapsed"/>
        <grid:AgDataGrid x:Name="grid" Grid.Row="0" ColumnsAutoWidth="True" PreviewVisibility="ForFocusedRow" PreviewTemplate="{StaticResource GridPreviewTemplate}" 
          FocusedRowChanged="grid_FocusedRowChanged" NewDataRow="grid_NewDataRow">
            <grid:AgDataGrid.Columns>
                <grid:AgDataGridTextColumn FieldName="LastName" TextWrapping="Wrap"/>
                <grid:AgDataGridTextColumn FieldName="FirstName"/>
                <grid:AgDataGridTextColumn FieldName="Title"/>
                <grid:AgDataGridDateColumn FieldName="BirthDate"/>
                <grid:AgDataGridTextColumn FieldName="HomePhone"/>
            </grid:AgDataGrid.Columns>
        </grid:AgDataGrid>
    </Grid>
    
</UserControl>
